// pages/serve/transcript/transcript.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
  },
  //查看错题
  problemClcik(e) {
    wx.navigateTo({
      url: '/pages/serve/problem/problem',
    })
  },
  //重考
  examClick(e){
    wx.navigateTo({
      url: '/pages/serve/exam/exam',
    })
  },
  /**分享微信好友 */
  shares(e) {
    var that = this
    // shareAppMessage: ok,
    wx.showShareMenu({
      withShareTicket: true,
      complete: function (res) {
      }
    })
    // var val = app.searchWord
    // // behaviors.behaviors('shares', app.searchWord, '', val.substring(val.indexOf("_") + 1));

    // var animation = wx.createAnimation({
    //   duration: 1000,
    //   timingFunction: 'linear'
    // })
    // that.animation = animation
    // animation.translateY(600).step()
    // that.setData({
    //   animationData: animation.export()
    // })
    // setTimeout(function () {
    //   animation.translateY(0).step()
    //   that.setData({
    //     animationData: animation.export(),
    //     chooseSize: false
    //   })
    //   // wx.showTabBar({}) //显示TabBar
    // }, 200)
    // this.setData({
    //   collected: "false"
    // });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var that = this
    let grade = 89 //分数
    let mistake = options.no //答错
    let residue = 0 //未做
    console.log(app.titleStudy)
    if (app.titleStudy == 1){
      grade = options.yes
      residue = 100 - options.yes - options.no
    }
    if (app.titleStudy == 4) {
      grade = options.yes * 2
      residue = 50 - options.yes - options.no
    }

    let second = options.time //用时
    let timeMin = parseInt(second / 60)
    let timeS = Math.ceil(second % 60)
    if (timeMin < 10) {
      timeMin = "0" + timeMin
    }
    if (timeS < 10) {
      timeS = "0" + timeS
    }
    that.setData({
      timeMin: timeMin,
      timeS: timeS,
      grade: grade,
      mistake: mistake,
      residue:residue
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var that = this
    let val = app.searchWord
    console.log(val)
    console.log(that.data.share_word)
    return {
      title: that.data.share_word,
      path: '/pages/serve/serve?id=share_' + val.substring(val.indexOf("_") + 1),
      success: function (res) {

      },
      fail: function (res) {
        // 分享失败
      }
    }
  }
})